class Person(object):

    # 初始化,相当于Java的构造方法
    def __init__(self, name, age):
        print('我初始化了')
        self.name = name
        self.age = age

    def eat(self, food):
        print(self.name + '在吃' + food)

    def sleep(self, hour):
        print(self.name + '睡了' + str(hour) + '个小时')

    # 相当于Java toString方法重写
    def __str__(self):
        return self.name + ' ' + str(self.age)

    # 对象销毁时调用
    def __del__(self):
        self.__private()
        print('del  ' + self.name)

    @staticmethod
    def __private():
        print("这是一个私有方法")


Jim = Person('Jim', 2)
Jim.eat('海鲜')
Jim.sleep(3)
# Jim.__private()
print(Jim)

Tom = Person('Tom', 3)
Tom.eat('黄焖鸡')
